<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;
use app\model\not_del\UserModel as NotDelUserModel;

/**
 * 干预人群
 */
class InterfereUserModel extends BaseModel
{
    protected $name = 'interfere_user';

    /**
     * 评估人
     * @return BelongsTo
     */
    public function opinionUser(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'opinion_uid')->bind([
            'opinion_name' => 'name',
        ]);
    }

    /**
     * 评估人
     * @return BelongsTo
     */
    public function opinionUser2(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'opinion2_uid')->bind([
            'opinion2_name' => 'name',
        ]);
    }

    /**
     * 评估人
     * @return BelongsTo
     */
    public function opinionUser3(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'opinion3_uid')->bind([
            'opinion3_name' => 'name',
        ]);
    }
    /**
     * 评估结果负责人
     * @return BelongsTo
     */
    public function evaluateUser(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'evaluate_uid')->bind([
            'evaluate_name' => 'name',
            'evaluate_role_name' => 'role_name',
        ]);
    }

    /**
     * 移动人
     * @return BelongsTo
     */
    public function moveUser(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'move_uid')->bind([
            'move_name' => 'name'
        ]);
    }

    /**
     * 用户
     * @return BelongsTo
     */
    public function user2(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class,'uid')->bind([
            'user_sex' => 'sex',
            'department_id',
        ]);
    }

    /**
     * 用户
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class,'uid')->bind([
            'user_name' => 'name',
            'user_avatar' => 'avatar',
            'user_sex' => 'sex',
            'user_age' => 'age',
            'phone',
            'province_name',
            'city_name',
            'area_name',
            'user_number',
            'username',
            'student_status',
            'unit_name',
            'role_name',
            'department_id',
            'department_name',
            'departmentAdmins',
            'political_outlook',
            'marital_status',
            'nation',
            'address',
            'native_place',
            'birthday',
            'id_card'
        ]);
    }

    /**
     * 关联操作人
     * @return BelongsTo
     */
    public function OperatorUser(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'operator_uid')->bind([
            'operator_name' => 'name',
            'operator_role_name' => 'role_name',
            'role_id' => 'role_id'
        ]);
    }

    /**
     * 关联申请人
     * @return BelongsTo
     */
    public function applicantUser(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'applicant_uid')->bind([
            'applicant_name' => 'name'
        ]);
    }

    /**
     * 关注用户
     * @return BelongsTo
     */
    public function FollowUser(): BelongsTo
    {
        return $this->belongsTo(FollowUserModel::class,'follow_id')->bind([
            'follow_channel' => 'channel',
            'follow_channel_id' => 'channel_id',
            'follow_time' => 'time',
            'follow_level' => 'level',
            'follow_reason' => 'reason',
            'follow_up_content' => 'up_content',
            'follow_up_num' => 'up_num',
            'follow_operator_name' => 'operator_name',
            'follow_operator_role_name' => 'operator_role_name',
        ]);
    }

    /**
     * 异常行为表现关系表
     * @return HasMany
     */
    public function InterfereBehavior(): HasMany
    {
        return $this->hasMany(InterfereBehaviorModel::class,'interfere_id');
    }

    /**
     * 评估风险等级关系表
     * @return BelongsTo
     */
    public function CrisisLevel(): BelongsTo
    {
        return $this->belongsTo('CrisisLevelModel','level_id')->bind(['level_name'=>'name','level_explain' => 'explain']);
    }

    /**
     * 危机问题关系表
     * @return BelongsTo
     */
    public function CrisisType(): BelongsTo
    {
        return $this->belongsTo('CrisisTypeModel','type_id')->bind(['type_name'=>'name']);
    }
}